package kusterordonio.interfaz;

import java.awt.Color;
import java.awt.event.KeyEvent;
import java.util.*;
import kusterordonio.dominio.*;

public class VentanaTelefonos extends javax.swing.JFrame {
    
    private SistemaCarne modelo;
    private Ninio niño;
    private boolean caso;

    /** Creates new form VentanaTelefonos */
    public VentanaTelefonos() {
        initComponents();
        jBtnSalir.setMnemonic(KeyEvent.VK_S);       
    }
    
    public VentanaTelefonos(SistemaCarne unSistema, Ninio unNiño, boolean unCaso) {
        modelo = unSistema;
        niño = unNiño;
        caso = unCaso;
        initComponents();
        cargarDatos();
        controlGenero();
        controlEdicion();
    }
    
    @SuppressWarnings("unchecked")
    
    //Sólo permite la edición si el  actor es padre, madre o tutor
    public void controlEdicion(){
        jTable1.setEnabled(!caso);
    }
    
    public void cargarDatos(){
        jLabelNombre.setText(niño.toString());
        jTable1.setValueAt(niño.getCarne().getTelefImportantes()[0], 0, 0);
        jTable1.setValueAt(niño.getCarne().getTelefImportantes()[1], 1, 0);
        jTable1.setValueAt(niño.getCarne().getTelefImportantes()[2], 2, 0);
        jTable1.setValueAt(niño.getCarne().getTelefImportantes()[3], 3, 0);
        jTable1.setValueAt(niño.getCarne().getTelefImportantes()[4], 4, 0);
    }
    
    public void controlGenero(){
        if (!niño.isSexo()){
            jPanel1.setBackground(new java.awt.Color(255, 153, 0));
        }
    }
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jBtnSalir = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jLabelTitular = new javax.swing.JLabel();
        jLabelNombre = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Teléfonos importantes");
        setBackground(new java.awt.Color(255, 255, 255));
        setBounds(new java.awt.Rectangle(200, 100, 0, 0));
        setMinimumSize(new java.awt.Dimension(560, 490));
        setResizable(false);
        getContentPane().setLayout(null);

        jPanel1.setBackground(new java.awt.Color(51, 153, 0));
        jPanel1.setMinimumSize(new java.awt.Dimension(560, 560));
        jPanel1.setLayout(null);

        jBtnSalir.setText("Salir");
        jBtnSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnSalirActionPerformed(evt);
            }
        });
        jPanel1.add(jBtnSalir);
        jBtnSalir.setBounds(240, 425, 80, 22);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Teléfonos importantes");
        jPanel1.add(jLabel1);
        jLabel1.setBounds(20, 20, 240, 22);

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setText("Apoyo a la mujer víctima de la violencia 08001414");
        jPanel1.add(jLabel2);
        jLabel2.setBounds(50, 250, 310, 15);

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("Atención a usuarios MSP 08004444");
        jPanel1.add(jLabel3);
        jLabel3.setBounds(50, 70, 220, 15);

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setText("Emergencias 911");
        jPanel1.add(jLabel4);
        jLabel4.setBounds(50, 100, 220, 15);

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel5.setForeground(new java.awt.Color(255, 255, 255));
        jLabel5.setText("Intoxicaciones (CIAT) 1722");
        jPanel1.add(jLabel5);
        jLabel5.setBounds(50, 130, 220, 15);

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel6.setForeground(new java.awt.Color(255, 255, 255));
        jLabel6.setText("Línea azul (INAU) 08005050");
        jPanel1.add(jLabel6);
        jLabel6.setBounds(50, 160, 220, 15);

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel7.setForeground(new java.awt.Color(255, 255, 255));
        jLabel7.setText("Bomberos 104");
        jPanel1.add(jLabel7);
        jLabel7.setBounds(50, 190, 220, 15);

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel8.setForeground(new java.awt.Color(255, 255, 255));
        jLabel8.setText("Jefatura 1909");
        jPanel1.add(jLabel8);
        jLabel8.setBounds(50, 220, 220, 15);

        jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/kusterordonio/recursos/doctora.gif"))); // NOI18N
        jPanel1.add(jLabel9);
        jLabel9.setBounds(370, 60, 160, 250);

        jScrollPane1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N

        jTable1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null},
                {null},
                {null},
                {null},
                {null}
            },
            new String [] {
                "Otros teléfonos importantes"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jTable1.setRowHeight(20);
        jScrollPane1.setViewportView(jTable1);
        jTable1.getColumnModel().getColumn(0).setResizable(false);

        jPanel1.add(jScrollPane1);
        jScrollPane1.setBounds(50, 280, 310, 130);

        jLabelTitular.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabelTitular.setForeground(new java.awt.Color(255, 255, 255));
        jLabelTitular.setText("Titular:");
        jLabelTitular.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jPanel1.add(jLabelTitular);
        jLabelTitular.setBounds(270, 20, 50, 20);

        jLabelNombre.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabelNombre.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jPanel1.add(jLabelNombre);
        jLabelNombre.setBounds(330, 20, 220, 20);
        jPanel1.add(jSeparator1);
        jSeparator1.setBounds(0, 50, 560, 10);

        getContentPane().add(jPanel1);
        jPanel1.setBounds(0, 0, 560, 460);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jBtnSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnSalirActionPerformed
        String primero = jTable1.getValueAt(0,0).toString();
        String segundo = jTable1.getValueAt(1,0).toString();
        String tercero = jTable1.getValueAt(2,0).toString();
        String cuarto = jTable1.getValueAt(3,0).toString();
        String quinto = jTable1.getValueAt(4,0).toString();
        niño.getCarne().cargarTelefonos(primero, segundo, tercero, cuarto, quinto);
        this.dispose();
    }//GEN-LAST:event_jBtnSalirActionPerformed
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBtnSalir;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabelNombre;
    private javax.swing.JLabel jLabelTitular;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTable jTable1;
    // End of variables declaration//GEN-END:variables
}
